﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace OnlineJobPortal.Models
{
    public class UserRepository : IUserRepository
    {
        JobPortalEntities7 entityObj = new JobPortalEntities7();
        public List<Job> SearchCategory(string category_name)
        {
            if (category_name.Equals("Admin"))
           {
               var Jobdata = from j in entityObj.Jobs
                             where j.JobCategory == category_name
                               select j;
              var list = Jobdata.ToList();
              return list;
            }
            if (category_name.Equals("Marketing"))
            {
                var Jobdata = from j in entityObj.Jobs
                              where j.JobCategory == category_name
                              select j;
                var list = Jobdata.ToList();
                return list;
            }
            if (category_name.Equals("Engineering"))
            {
                var Jobdata = from j in entityObj.Jobs
                              where j.JobCategory == category_name
                              select j;
                var list = Jobdata.ToList();
                return list;
            }
            if (category_name.Equals("IT"))
            {
                var Jobdata = from j in entityObj.Jobs
                              where j.JobCategory == category_name
                              select j;
                var list = Jobdata.ToList();
                return list;
            }
            if (category_name.Equals("HR"))
            {
                var Jobdata = from j in entityObj.Jobs
                              where j.JobCategory == category_name
                              select j;
                var list = Jobdata.ToList();
                return list;
            }
            if (category_name.Equals("Hardware"))
            {
                var Jobdata = from j in entityObj.Jobs
                              where j.JobCategory == category_name
                              select j;
                var list = Jobdata.ToList();
                return list;
            }
            if (category_name.Equals("Accounting"))
            {
                var Jobdata = from j in entityObj.Jobs
                              where j.JobCategory == category_name
                              select j;
                var list = Jobdata.ToList();
                return list;
            }
            if (category_name.Equals("Banking"))
            {
                var Jobdata = from j in entityObj.Jobs
                              where j.JobCategory == category_name
                              select j;
                var list = Jobdata.ToList();
                return list;
            }
            if (category_name.Equals("Finance"))
            {
                var Jobdata = from j in entityObj.Jobs
                              where j.JobCategory == category_name
                              select j;
                var list = Jobdata.ToList();
                return list;
            }
            if (category_name.Equals("Telecom"))
            {
                var Jobdata = from j in entityObj.Jobs
                              where j.JobCategory == category_name
                              select j;
                var list = Jobdata.ToList();
                return list;
            }
           return null ;
            
            
        }
        public Job JobDetails(int jobID)
        {
            Job jobData = entityObj.Jobs.First(x => x.JobID == jobID);
            return jobData;
           
        }
        public void ApplyForJob(ApplyforJob apply)
        {
            var applydata = entityObj.ApplyforJobs;
            applydata.Add(apply);
            entityObj.SaveChanges();
        }
    }
}